<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2020/4/26
 * Time: 17:22
 */

namespace app\common\model;


class Attack
{
    /**
     * @name: 危险等级转 字符串
     * @Param:
     * @Description:
     * @Author: foo
     * @Date: 2019-09-17 17:15:15
     */
    function dangerLevel2string ($level)
    {
        $data = array_column($this->dangerLevel(),'value','id');
        return isset($data[$level]) ? $data[$level] : '未知' ;
    }

    /**
     * @name: 危险度
     * @Param:
     * @Description:
     * @Author: foo
     * @Date: 2019-09-17 17:17:21
     */
    function dangerLevel ()
    {
        return [
            [
                'id' => 1,
                'value' => '低',
            ],
            [
                'id' => 2,
                'value' => '中',
            ],
            [
                'id' => 3,
                'value' => '高',
            ],
            [
                'id' => 4,
                'value' => '极高',
            ],
        ];
    }

    /**
     * @name: 处理方式
     * @Param:
     * @Description:
     * @Author: foo
     * @Date: 2019-09-17 17:26:19
     */
    function handle()
    {
        return [
            [
                'id' => 0,
                'value' => '禁止',
            ],
            [
                'id' => 1,
                'value' => '允许',
            ],
            [
                'id' => 2,
                'value' => '警告',
            ]
        ];
    }

    /**
     * @name: 处理方式转文字
     * @Param:
     * @Description:
     * @Author: foo
     * @Date: 2019-09-17 17:26:19
     */
    function handle2string($handle)
    {
        $data = array_column($this->handle(),'value','id');
        return isset($data[$handle]) ? $data[$handle] : '未知' ;
    }
}